package com.fzj.example.jdk18;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * ClassName: DateDemo
 * date: 2019/11/13 17:13
 * Description: TODO
 *
 * @author fanzj@bonree.com
 * @since JDK 1.8
 */
public class DateDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
        Callable< LocalDate > task = () -> {
            LocalDate date = LocalDate.parse("20180428", dtf);
            return date;
        };
        ExecutorService pool = Executors.newFixedThreadPool(10);
        List< Future<LocalDate> > list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(pool.submit(task));
        }
        for (Future<LocalDate> future : list) {
            System.out.println(future.get());
        }
        pool.shutdown();
    }
}
